﻿<%@ WebHandler Language="C#" Class="GetBc" %>

using System.Web;
using System.Data;
using Newtonsoft.Json;
using System;

public class GetBc : IHttpHandler
{

    public void ProcessRequest(HttpContext context)
    {
        string pid = StringHelper.SafeSqlInput(context.Request.QueryString["pid"]);
        string rq = StringHelper.SafeSqlInput(context.Request.QueryString["rq"]);

        DBHelper db = new DBHelper();
        DataTable dt;
        string sql = "";
        if (pid != "")
        {
            string[] arr = pid.TrimEnd('|').Split('|');
            for (int i = 0; i < arr.Length; i++)
            {
                pid += "'" + arr[i] + "',";
            }
            rq = Convert.ToDateTime(rq).AddDays(1).ToString("yyyy-MM-dd");
            pid = pid.Replace('|', ',').TrimEnd(',');
            sql = "select * from [v_A_Attendance] where userbh in(" + pid.TrimEnd(',') + ") and rq='" + rq + "' order by userbh,sign";
            dt = db.getList(sql);
            context.Response.ContentType = "application/json";
            context.Response.Write(JsonConvert.SerializeObject(dt));
        }
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}